package cn.itcast.dao;

import cn.itcast.domain.Account;
import cn.itcast.domain.DingDan;
import cn.itcast.entity.PageResult;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * 帐户dao接口
 */
@Repository
public interface AccountDao {

    // 查询所有账户
    @Select("select * from ssm where stye=0")
    public List<Account> findAll();

    // 保存帐户信息
    @Insert("insert into ssm (name,money) values (#{name},#{money})")
    public void saveAccount(Account account);

    //根据id查询用户
    @Select("select * from ssm where id = #{ id }")
    public Account findById(Integer id);

    /*
    分页
     */
    @Select("select id,name,money from ssm")
    Page<Account> findPage();

    //添加数据
    @Insert("insert into ssm (name,money) values (#{name},#{money})")
    public void add(Account account);

    /*
    物理删除
     */
    @Delete("delete from ssm where id=#{id}")
    void delete(Integer id);

    /*
    逻辑删除
     */
    @Update("update ssm set stye=1 where id=#{id}")
    void updateAndDelete(Integer id);

    //更新账户
    @Update("update ssm set name=#{name},money=#{money} where id=#{id}")
    void update(Account account);

}
